package com.ems.service.impl;

import com.ems.dao.MyDtoMapper;
import com.ems.dao.StudentDao;
import com.ems.dao.TeacherDao;
import com.ems.dto.PersonInfo;
import com.ems.service.PublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PublicServiceImpl implements PublicService {

    @Autowired
    StudentDao studentDao;

    @Autowired
    TeacherDao teacherDao;

    @Autowired
    MyDtoMapper myDtoMapper;
    @Override
    public PersonInfo personInfo(String username,Integer identity) {
        int i;
        if(identity == 0)
        //注意参数的校验，用户名不存在应该抛出异常
        {
            i = studentDao.queryIDbyUsername(username);
            return myDtoMapper.personInfoStu(i);
        }
        else if(identity == 1)
        {
            i = teacherDao.queryIDbyUsername(username);
            return myDtoMapper.personInfoTea(username,i);
        }
        return null;
    }
}
